﻿using System.ComponentModel.DataAnnotations;
using WebApplication1.Core.Domain.Entities;

namespace WebApplication1.Core.DataTransferObject {
    public class SheQuRequest {

        public ushort? SheQuID { get; set; }

        [Required(ErrorMessage = "社区名称不能为空")]
        public string MingCheng { get; set; }

        public string? DianHua { get; set; }

        public string? ShuJi { get; set; }

        public string? ShuJiDianHua { get; set; }

        public SheQu ToSheQu() {
            if(this.SheQuID != null) {
                return new SheQu() { SheQuID = this.SheQuID!.Value, MingCheng = this.MingCheng, DianHua = this.DianHua, ShuJi = this.ShuJi, ShuJiDianHua = this.ShuJiDianHua };
            } else {
                return new SheQu() { MingCheng = this.MingCheng, DianHua = this.DianHua, ShuJi = this.ShuJi, ShuJiDianHua = this.ShuJiDianHua };
            }
        }

        public SheQuResponse toSheQuResponse() {
            if(this.SheQuID != null) {
                return new SheQuResponse() { SheQuID = this.SheQuID!.Value, MingCheng = this.MingCheng, DianHua = this.DianHua, ShuJi = this.ShuJi, ShuJiDianHua = this.ShuJiDianHua };
            } else {
                return new SheQuResponse() {
                    MingCheng = this.MingCheng, DianHua = this.DianHua, ShuJi = this.ShuJi, ShuJiDianHua = this.ShuJiDianHua
                };
            }
        }
    }
}
